<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        /* 打印 undefined*/
        var num = 10;
        fun();

        function fun() {
            console.log(num);
            var num = 20;
        }


        /*上面代码相当于*/
        var num;    //变量提升

        function fun() {    //函数提升
            var num;         //局部变量提升
            console.log(num);
            num = 20;
        }

        num = 10;
        fun();





    </script>
</head>
<body>

</body>
</html>